package com.example.redis_redisson_demo.web.redis;

import com.example.redis_redisson_demo.common.utils.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redislog")
public class RedisLogController {

    // 手动打印日志需要引入如下语句
    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());

    @RequestMapping("/simulateUNKNOWNERROR")
    public R simulateERROR(){
        // 模拟因为未定义异常而抛出同时导致的日志ERROR记录
        int i = 1 / 0;
        return R.ok();
    }
    @RequestMapping("/simulateKNOWNERROR")
    public R simulateINFO(){
        // 模拟合法调用的ERROR
        LOGGER.error("合法输出ERROR");
        return R.ok();
    }
}
